<template>
	<view class="bottomPopup-root">
		<u-popup :show="currentOpen" mode="bottom" @close="closePopup">
			<view class="top-container">
				<view class="button" @click="cancel">取消</view>
				<view class="title">
					{{title}}
				</view>
				<view :style="showSubmitBt ? {} : {visibility: 'hidden'}" class="button" @click="submit">确定</view>
			</view>
			<view class="body-container">
				<slot></slot>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		props: {
			open: {
				type: Boolean,
				default: false
			},
			title: {
				type: String
			},
			showSubmitBt: {
				type: Boolean,
				default: true
			}
		},
		data() {
			return {
				currentOpen: false,
			}
		},
		watch: {
			open() {
				this.currentOpen = this.open
			}
		},
		methods: {
			cancel() {
				this.$emit('cancel')
			},
			submit() {
				this.$emit('submit')
			},
			closePopup() {
				this.currentOpen = false;
				this.$emit('close')
			},
		},
		created() {
			this.currentOpen = this.open
		}
	}
</script>

<style lang="scss">
	.bottomPopup-root {
		background: #fff;
		height: max-content;

		.top-container {
			display: flex;
			justify-content: space-between;
			box-sizing: border-box;
			width: 100%;
			padding: 30rpx 20rpx;
			border-bottom: 2rpx solid #EFEFEF;

			.button {
				color: #AD2325;
				font-size: 30rpx;
				width: max-content;
			}

			.title {
				font-size: 30rpx;
				width: max-content;
			}
		}

		.body-container {
			box-sizing: border-box;
			width: 100%;
			padding: 30rpx 20rpx;
		}
	}
</style>
